package com.gesee.zyspps.adapter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.gesee.zys.R;
import com.gesee.zyspps.db.CmsDbNum;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

/**
 * 
* @ClassName: ShowTypeAdater
* @Description: TODO(显示小类)
* @author fujianxiong
* @date 2016年1月25日 下午2:37:50
*
 */
public class ShowTypeAdater extends BaseAdapter
{
    private Context mContext;
    private List list;
    private Map<String,String> map = new HashMap<String,String>();

    public ShowTypeAdater(Context ctx,Map<String,String> selectMap)
    {
        this.mContext = ctx;
        this.map = selectMap;
    }

    public void setList(List list)
    {
        this.list = list;
    }

    public List getList()
    {
        return list;
    }

    public int getCount()
    {
        return list == null ? 0 : list.size();
    }

    public Object getItem(int position)
    {
        return list.get(position);
    }

    public long getItemId(int position)
    {
        return 0;
    }

    public View getView(int position, View convertView, ViewGroup parent)
    {
        ViewHolder holder = null;
        if (convertView == null)
        {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.show_type_list, null);
            holder = new ViewHolder();
            holder.ckbox = (CheckBox) convertView.findViewById(R.id.ckbox);
            convertView.setTag(holder);
        }
        else
        {
            holder = (ViewHolder) convertView.getTag();
        }
        
        holder.ckbox.setText(list.get(position).toString());
        if(map!=null&&map.size()>0){
        	for(String key:map.keySet()){
        		if(map.get(key).equals(list.get(position).toString())){
        			Log.e("ck", map.get(key));
        			holder.ckbox.setChecked(true);
        		}
        	}
        }
        if(map.get("ALL")==null){
        	if(position == 0){
        		holder.ckbox.setChecked(false);
        	}
        }

        return convertView;
    }

    class ViewHolder
    {
        CheckBox ckbox;
    }

}
